<?php
/*
    cat_id
 */
define('IN_DOUCO', true);

// 强制在移动端中显示PC版
if (isset($_REQUEST['mobile'])) {
   setcookie('client', 'pc');
   if ($_COOKIE['client'] != 'pc') $_COOKIE['client'] = 'pc';
}

require (dirname(__FILE__) . '/include/init.php');

if ($_REQUEST['lang']) {
    $lang = $_REQUEST['lang'];
}else{
    $lang = 'zh';
}
require (dirname(__FILE__) . '/common.php');

$smarty->assign('dangqun_url', get_dangqun($lang));
$smarty->assign('zhaosheng_url', get_zhaosheng($lang));


if ($_REQUEST['type']) {
    if ($_REQUEST['id']){
        $query = $dou->select(
                $dou->table('product')
                , '*'
                , '`id` = \'' . $_REQUEST['id'] . '\''
        );
    }
    $product = $dou->fetch_array($query);
    $smarty->assign('product_name', $product['name']);
    $smarty->assign('product_content', $product['content']);
    $smarty->assign('type', '1');

}else{
    if ($_REQUEST['cat_id']){
        $cat_id = $_REQUEST['cat_id'];
        $query = $dou->select(
                $dou->table('article')
                , '*'
                , '`cat_id` = \'' . $cat_id . '\' and `lang` = \'' . $lang . '\'' 
                );
    }

    if ($_REQUEST['id']){
        $query = $dou->select(
                $dou->table('article')
                , '*'
                , '`id` = \'' . $_REQUEST['id'] . '\''
            );
    }

    $article = $dou->fetch_array($query);

    $smarty->assign('article', $article);
    $smarty->assign('article_content', $article['content']);
    $smarty->assign('article_title', $article['title']);

    $article['add_time'] = date("Y-m-d", $article['add_time']);
    $smarty->assign('article_add_time', $article['add_time']);
    $smarty->assign('type', '0');

    $smarty->assign('article_file1', $article['file1']);
    $smarty->assign('article_file2', $article['file2']);
    $smarty->assign('article_file3', $article['file3']);
}
$smarty->assign('lang', $lang);



// 赋值给模板-数据
$smarty->display('info.dwt');

?>
